package com.ft.adbix.core.view.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.ft.adbix.core.R;
import com.ft.adbix.core.response.Ad;
import com.ft.adbix.core.widget.roundedimageview.RoundedImageView;
import com.ft.adbix.utils.universalimageloader.core.ImageLoader;

public class RewardDetentionDialog extends BaseAdDialog {

    private final OnOperateListener listener;

    public RewardDetentionDialog(Context context, Ad adData, OnOperateListener listener) {
        super(context, adData);
        this.listener = listener;
    }

    @Override
    public int getDialogView() {
        return R.layout.adbix_layout_reward_detention_dialog;
    }

    @Override
    public void initView() {
        findViewById(R.id.adbix_library_iv_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    dismiss();
                    listener.onResumeAd();
                }
            }
        });
        findViewById(R.id.adbix_library_tv_continue_watch).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    dismiss();
                    listener.onResumeAd();
                }
            }
        });
        findViewById(R.id.adbix_library_tv_exit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    dismiss();
                    listener.onFinishAd();
                }
            }
        });
        findViewById(R.id.adbix_library_tv_function).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener!=null){
                    listener.onDownload();
                }
            }
        });
//        findViewById(R.id.adbix_library_fl_click).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                if(listener!=null){
//                    dismiss();
//                    listener.onResumeAd();
//                }
//            }
//        });
        TextView tvTitle = findViewById(R.id.adbix_library_tv_title);
        tvTitle.setText(adData.getTitle());
        TextView tvDesc = findViewById(R.id.adbix_library_tv_desc);
        tvDesc.setText(adData.getDesc());
        RoundedImageView ivIcon = findViewById(R.id.adbix_library_iv_app_icon);
        ImageLoader.getInstance().displayImage(adData.getAppPromotion().getAppIconUrl(), ivIcon);

    }

    public interface OnOperateListener {
        void onFinishAd();

        void onResumeAd();

        void onDownload();
    }

}
